﻿/*
=============================================================================
Author:魏宝辉通过CodeSmithe生成
CreatedTime:2012-8-11
Description:Sms_sending.aspx.cs页面代码
=============================================================================	
*/

using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Sms_sending : System.Web.UI.Page 
{

    string TableName = "Sms_sending";//表名
    static string SqlWhere = " 1=1 ";//过滤条件
    string GetCountSql = "select count(id)  from Sms_sending where " + SqlWhere ;
    string SqlTable = "select *  from Sms_sending where " + SqlWhere + "  order by id asc ";
    string ReturnPage = "Sms_sending.aspx";
    FTchina.SearchQuery.QueryModel qm = new FTchina.SearchQuery.QueryModel();//实例化模型

    protected void Page_Load(object sender, EventArgs e)
    {
        FTchina.basic.CheckAdmin(this);        
        FTchina.basic.ChkPoewr(this, FTchina.Api.htmlpath.GetCurrentPagePath());
 		if (!IsPostBack)
        {	
			 
            
             if (qm.WorkPage != ReturnPage)
            {
                qm.TableName = TableName;
                qm.GetCountSql = GetCountSql;
                qm.GetTableSql = SqlTable;
                qm.ReturnPage = ReturnPage;
                qm.SqlWhere = SqlWhere;
                qm.WorkPage = ReturnPage;

            }
             
            bindData(qm);
		}
    }
    protected void btn2task_Click(object sender, EventArgs e)
    {
        FTchina.basic.GetHttphtml("http://localhost:8080/smstask/send2task.aspx", System.Text.Encoding.UTF8);
        FTchina.JS.Alert("操作成功，进程后台执行");
        FTchina.JS.JavaScriptLocationHref("sms_sending.aspx");

    }
    protected void btn2target_Click(object sender, EventArgs e)
    {
        FTchina.basic.GetHttphtml("http://localhost:8080/smstask/send2target.aspx", System.Text.Encoding.UTF8);
        FTchina.JS.Alert("操作成功，进程后台执行");
        FTchina.JS.JavaScriptLocationHref("sms_sending.aspx");
    }
	 
    
    #region gvList显示

    private void bindData(FTchina.SearchQuery.QueryModel qm)
    {
       
        int pCurrentPage = (FTchina.basic.SafeRequest(Request["page"]).Length > 0) ? Convert.ToInt32(FTchina.basic.SafeRequest(Request["page"])) : 1;
        int pageSize = 15;//每页的数据
        int AllCount = Convert.ToInt32(FTchina.shujuku.GetDataTable(qm.GetCountSql).Rows[0][0].ToString());//数据总条目数
        litpager.Text = FTchina.Api.Pager.GetPagerWithPageName(qm.GetTableSql, AllCount, pCurrentPage, pageSize, qm.ReturnPage);
        gvList.DataSource = FTchina.shujuku.ShowForPage(qm.TableName,qm.SqlWhere, pCurrentPage, pageSize);
        gvList.DataBind();
       
    }
    #endregion


    
      

    #region GridView等控件导出到Excel
    protected void btnexcel_Click(object sender, EventArgs e)
    {
        //将分页去除
        gvList.Width = Unit.Percentage(100);
        gvList.AutoGenerateColumns = false;
        gvList.AllowPaging = false;
        string GetDateSql = string.Format(SqlTable, TableName);
        DataSet ds = FTchina.shujuku.GetDataSet(GetDateSql);
        gvList.DataSource = ds;
        gvList.DataBind();

        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter(stringWrite);
        gvList.RenderControl(writer);

        FTchina.Api.ToExcel.HtmlTableToExcel(stringWrite.ToString());
    }
    public override void VerifyRenderingInServerForm(Control control)
    {
        // 覆盖VerifyRenderingInServerForm方法，非常重要，否则系统会报错
        //base.VerifyRenderingInServerForm(control);
    }
    #endregion

    
}




 

